<?php
/**
* Author: Porlock
* Link: www.porlockz.com
* Date: 2018-04-29 18:05:51
* Last Modified time: 2018-04-29 18:05:52
* Use：展示答对题目情况
*/
session_start();
require_once ('../init.php');
require_once ('includes/lib/func_rightCtrl.php');
require_once ('includes/lib/func_register.php');
// 权限控制
player_rightCtrl();
echo <<<tableHeader
      <script type="text/javascript" src="layui/layui.all.js"></script>
      <div>
            <div class="row">
                  <div class="col-md-12">
                        <table class="layui-table">
                              <thead>
                                    <tr align="center">
                                    <th bgcolor="white"><b>Name</b></th> 
                                    <th bgcolor="white"><b>Date</b></th> 
                                    <th bgcolor="white"><b>Rank</b></th>
                                    </tr>
tableHeader;
$title = $_GET['title'];
$query_solved = "SELECT * FROM `solved_situation` WHERE `title` = :title ORDER BY `submit_time` ASC";
$sth_solved = $dbh->prepare($query_solved);
$sth_solved -> bindParam(":title",$title);
$sth_solved -> execute();
$solverNum = $sth_solved->rowCount();
$solver_result = $sth_solved -> fetchAll();
if($solverNum === 0){
      echo <<<table
                                    <tr align="center">
                                        <td colspan="3">暂未答出</td>
                                    </tr>
table;
}else{
      for($i = 0;$i < $solverNum; $i++){            
            $solver_uid             = $solver_result[$i]['uid'];
            $solver_submit_time     = $solver_result[$i]['submit_time'];
            $rank = $i + 1;
            $query_nickname = "SELECT `nickname` FROM `user` WHERE `uid` = :uid";
            $sth_nickname = $dbh->prepare($query_nickname);
            $sth_nickname -> bindParam(":uid",$solver_uid);
            $sth_nickname -> execute();
            $solver_nickname = $sth_nickname->fetch()[0];
      echo <<<EOT
                                    <tr align="center">
                                    <td bgcolor="white">$solver_nickname</td>
                                    <td bgcolor="white">$solver_submit_time</td>
                                    <td bgcolor="white">$rank</td>
                                    </tr>
EOT;
}
}
echo <<<tableTail
                                    
                              </thead>
                              <tbody id="chal-solves-names">
                              </tbody>
                        </table>
                  </div>
            </div>
      </div>
tableTail;
?>